package org.mags.dao.common;

import java.io.Serializable;

public class Limits implements Serializable {
	private long firstRecord = 0;
	private long numRecords = -1;
	private static final Limits allRecs = new Limits(0, -1);
	private static final Limits oneRec = new Limits(0, 1);
	public static Limits oneRec() {
		return oneRec;
	}
	public static Limits allRecs() {
		return allRecs;
	}
	public static Limits numRecs(long numRecords) {
		return new Limits(0, numRecords);
	}
	public Limits(long firstRecord, long numRecords) {
		if(firstRecord<0)
			throw new RuntimeException("first record limit can't be less than zero");
		this.firstRecord = firstRecord;
		if(numRecords!=-1 && numRecords<=0)
			throw new RuntimeException("number of records can't be less than or equal to zero");
		this.numRecords = numRecords;
	}
	public long getFirstRecord() {
		return firstRecord;
	}
	public long getNumRecords() {
		return numRecords;
	}
}
